package com.example.elmmerchants.Sign;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.example.elmmerchants.R;

import java.util.UUID;

public class Sign_Page extends AppCompatActivity {

    private FrameLayout frameLayout;
    private TextView create_shop_btn, password_login_btn, otp_login_btn;

    String android_id;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_page);

        android_id = getIntent().getStringExtra("android_id");

        set_page(new Password_Login_Method(getApplicationContext(), android_id));

        frameLayout = findViewById(R.id.sign_page_frame_layout);

        create_shop_btn = findViewById(R.id.create_shop_page);

        otp_login_btn = findViewById(R.id.otp_login_method);

        password_login_btn = findViewById(R.id.password_login_method);
        password_login_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                password_login_btn.setTextColor(Color.BLACK);
                otp_login_btn.setTextColor(Color.GRAY);

                set_page(new Password_Login_Method(getApplicationContext(), android_id));
            }
        });

        otp_login_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                password_login_btn.setTextColor(Color.GRAY);
                otp_login_btn.setTextColor(Color.BLACK);

                set_page(new OTP_Login_Method(getApplicationContext(), android_id));
            }
        });
    }

    public void set_page(Fragment fragment) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.sign_page_frame_layout, fragment)
                .commit();
    }
}